<template>
    <div class="mui-numbox" data-numbox-min='0'>
        <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
        <input id="test" class="mui-input-numbox" type="number"
        ref="numbox"
        :value="$store.getters.renderGoodsNum[this.goodsId]"
        @change="numChange"/>
        <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
    </div>
</template>

<script>
    import mui from '../../lib/mui/js/mui.min.js'; //这东西为什么不能在全局引入？
    export default {
        mounted () {
            mui('.mui-numbox').numbox();
        },
        methods: {
            numChange () { // 数量改变时，把改变的数量给状态管理器，更新数据
                this.$store.commit('updateGoodsNum', { id: this.goodsId, num: this.$refs.numbox.value } );
                console.log(this.$refs.numbox.value);
                console.log(this.goodsId);
            },
        },
        props: ['goodsId'],
    }
</script>

<style lang="scss" scoped>
    .mui-numbox {
        height: 25px;
    }
</style>
